<?php
namespace Api\Controller;
use Api\Controller\CommonController;
class RegionController extends CommonController {
    public function index(){
		
    }
    
    public function regionList(){
		
		isset($_POST['level'])?$level =intval($_POST['level']):$level=0;
		isset($_POST['parent'])?$parent =intval($_POST['parent']):$parent=0;
		
		$where = array();
		if($level!=0){
			$where['level'] = $level;
		}
		if($parent!=0){
			$where['parent'] = $parent;
		}
		$list = D("Region")->where($where)->order('sort')->select();
		$all = array('regionID'=>'0','name'=>'全部','level'=>'0','parentID'=>'0','sort'=>'-1');
		array_unshift($list, $all);
		//var_dump($list);
		
    	$this->_returnJson(array("result"=>1,"list"=>$list));
    }
    
    
}